<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <h1>员工管理系统</h1>
    <div v-if="isLogin">
        <input type="text" v-model="name" placeholder="请输入员工姓名">
        <input type="button" value="添加" @click="add()">
        <a href="javascript:void(0)" @click="notlog()">退出登录</a>
    </div>
    <div v-else>
        <a href="">注册</a>
        <a href="javascript:void(0)" @click="log()">登录</a>
    </div>
    <table border="1">
        <caption>员工列表</caption>
        <tr>
            <td>编号</td>
            <td>姓名</td>
            <td v-if="isLogin">操作</td>
        </tr>
        <tr v-for="(name,i) in arr">
            <td>{{i+1}}</td>
            <td>{{name}}</td>
            <td v-if="isLogin" @click="del(i)"><a href="javascript:void(0)">删除</a></td>
        </tr>
    </table>
</div>

<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<script>
  let v = new Vue({
    el:"body>div",
    data:{
        isLogin:false,
        arr:["悟空","八戒","沙僧"],
        name:""
    },
    methods:{
        log(){
            v.isLogin = true
        },
        notlog(){
            v.isLogin = false
        },
        add(){
            v.arr.push(v.name)
        },
        del(i){
            v.arr.splice(i,1)
        }

    }
  })
</script>
</body>
</html>